package org.lg.framework.register;

import java.net.URL;
import java.util.*;

public class RemoteRegister {
    public static Map<String, List<URL>> register = new HashMap();
    //远程注册中心 用redis zookeeper实现 每次新注册添加只需要一个url 但返回返回url list 方便用户进行 负载均衡（随机 轮询）
    public static void register(String interfaceName,URL url){
        List<URL> urls = register.get(interfaceName);
        if(!Optional.ofNullable(urls).isPresent()){
            urls = new ArrayList<URL>();
        }
        urls.add(url);
        register.put(interfaceName, urls);//ctrl+shift+enter补全分号
    }

    public static List<URL> get(String interfaceName){
        return register.get(interfaceName);
    }



}
